/*
 * @Description: 
 * @Author: changqing
 * @Date: 2021-08-29 22:59:28
 * @LastEditTime: 2021-08-29 23:00:43
 * @LastEditors: changqing
 * @Usage: 
 */
var { of,timer,interval,Subject } = require("rxjs");
var { map, take,combineAll } = require("rxjs/operators");

const transformStreamToObservable = round =>
  timer(0, 1000).pipe(
    map(data => `数据流 ${round}: ${++data}`),
    take(3)
  );
  
const subject = new Subject();

const stream = subject.pipe(map(round => transformStreamToObservable(round)));

stream.pipe(combineAll())
  .subscribe(result => console.log(result));

subject.next(1);

setTimeout(() => {
  subject.next(2);
   subject.complete();
}, 3000);


 //  ["数据流 1: 1", "数据流 2: 1"]
 //  ["数据流 1: 2", "数据流 2: 1"]
 //  ["数据流 1: 2", "数据流 2: 2"]
 //  ["数据流 1: 3", "数据流 2: 2"]
 //  ["数据流 1: 3", "数据流 2: 3"]